home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 79 / maccd 79.iso / multimedial / GL Tron / Source / gltron / sound_libmikmod.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-13  |  1.3 KB  |  78 lines  |  [TEXT/CWIE]

  1. #include "sound.h"
  2.  
  3. /* the following functions do nothing and are provided for
  4.    compatibility only */
  5.  
  6. void playGameFX(int fx) { }
  7. void playMenuFX(int fx) { }
  8. void playEngine() { }
  9. void stopEngine() { }
  10. void shutdownSound() { }
  11.  
  12. /* here is the music stuff */
  13.  
  14. MODULE* sound_module;
  15.  
  16. int initSound() {
  17.   char *drivers;
  18.   md_mode |= DMODE_SOFT_MUSIC;
  19.   md_mixfreq = 44100;
  20.   md_reverb = 0;
  21.  
  22. #ifdef WIN32
  23.   MikMod_RegisterDriver(&drv_win);
  24. #else
  25.   MikMod_RegisterAllDrivers();
  26. #endif
  27.   drivers = MikMod_InfoDriver();
  28.   printf("%s\n", drivers);
  29.   free(drivers);
  30.  
  31.   MikMod_RegisterAllLoaders();
  32.  
  33.   if(MikMod_Init("")) {
  34.     printf("Cound not initialize sound: %s\n",
  35.        MikMod_strerror(MikMod_errno));
  36.     return 1;
  37.   }
  38.   return 0;
  39. }
  40.  
  41. void loadSound(char* name) {
  42.   sound_module = Player_Load(name, 64, 0);
  43.   if(!sound_module) {
  44.     fprintf(stderr, "Could not load module: %s\n",
  45.        MikMod_strerror(MikMod_errno));
  46.   }
  47. }
  48.  
  49. void playSound() {
  50.   if (sound_module) {
  51.     Player_Start(sound_module);
  52.     printf("sound startet\n");
  53.   }
  54. }
  55.  
  56. void stopSound() {
  57.   Player_Stop();
  58.   printf("sound stopped");
  59. }
  60.  
  61. void deleteSound() {
  62.   if(Player_Active())
  63.     Player_Stop();
  64.   if(sound_module)
  65.     Player_Free(sound_module);
  66.   MikMod_Exit();
  67. }
  68.  
  69. void soundIdle() {
  70.   if(Player_Active())
  71.     MikMod_Update();
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.